The present invention relates to image filtering. More specifically, it relates to mirror-mode edge handling in image filtering.
Filtering image data typically involves applying a filter thereto. FIG. 1 illustrates the conceptual application of a filter to image data. In FIG. 1, image data 105 (which may also herein be referred to as image 105 or image frame 105) has a filter 110 applied thereto. Image data 105 represents an image frame and includes five rows and six columns of pixels. The five rows in image data 105 include rows j0 to j4. The six columns in image data 105 include columns i0 to i5. Each pixel in image data 105 is identified by its row and column position. For example, pixel i2,j1 is the pixel on row j1 at column i2. Filter 110 is a two dimensional filter that includes filtering coefficients c0 to c9, as shown in FIG. 1. Filter 110 may also herein be referred to as a kernel window.
Filtering the image data involves filtering each pixel of the image data by the filter. The filtering typically begins on the first row of the image data, e.g., on row j0 of image data 105. More specifically, the filtering typically begins on the pixel on the first column of the first row, e.g., i0,j0, and proceeds in raster order to the other columns, i.e., from left to right, on that row. Thereafter the filtering proceeds to the next row, e.g., row j1, whose pixels are also processed from left to right. This continues until all the rows of the image data are filtered.
Filtering a pixel of an image data typically involves conceptually centering the kernel window around the pixel and applying filtering coefficients of the filter to the respective pixels over which they are positioned. For example, in FIG. 1, filter 110 is centered around pixel i2,j2, at which position it filters pixel i2,j2 of image data 105. The result of filtering pixel i2,j2 by filter 110 is (i1j1)×c0+(i2j1)×c1+(i3j1)×c2+(i1j2)×c3+(i2j2)×c4+(i3j2)×c5+(i1j3)×c6+(i2j3)×c7+(i3j3)×c8. After filtering pixel i2,j2, filter 110 would be applied to pixel i3,j2 and the result of the filtering would be (i2j1)×c0 (i3j1)×c1+(i4j1)×c2+(i2j2)×c3+(i3j2)×c4+(i4j2)×c5+(i2j3)×c6+(i3j3)×c7+(i4j3)×c8. It is to be noted that the resulting sum for filtering a pixel data typically need not be averaged as such averaging factor is typically already taken into account in the filtering coefficient of the filter, e.g., the c0 to c8 in the example of FIG. 1.
In the situation illustrated in FIG. 1, the kernel window covers only pixels within the image data area, i.e., the kernel window is entirely within the image. However, when filtering pixels at or near the edges or boundaries 106, 107, 108, and 109 of an image data area, part of the kernel window would typically fall outside of the image data area, which may herein be referred to as the filter being off the image data. This would result in a lower filtering value for such pixels, thus producing artifacts around the edges of the filtered image. In order to reduce such artifacts, the pixel data around the edges is mirrored about the edges.
FIG. 2 illustrates filtering of image data using mirroring. In FIG. 2, image data 205 is filtered using filter 210. In FIG. 2, the first row of pixels below horizontal boundary 206 (i.e., pixels in row j0) are mirrored above horizontal boundary 206. Similarly, the first column of pixels to the right of vertical boundary 209 (i.e., pixels in column i0) are mirrored to the left of vertical boundary 209. In fact, not only pixels to the right of vertical boundary 209, but pixels to the right of a line containing vertical boundary 209 are mirrored to the left of such a line. Similarly, the mirroring about boundary 206 is also extended along a line containing boundary 206. In FIG. 2, filter 210 is positioned above image data 205 (and its associated mirrored data) for filtering pixel i0,j0. The result of such filtering is (i0j0)×c0+(i0j0)×c1+(i1j0)×c2+(i0j0)×c3+(i0j0)×c4+(i1j0)×c5+(i0j1)×c6+(i0j1)×c7+(i1j1)×c8.
In FIG. 2, the mirroring applies to only the first row (row j0) and the first column (column i0) because the filter 210 is a 3 by 3 filter which at most would extend one row or column outside the image data area when filtering pixels along boundaries 206 and 209. If a larger filter were used, e.g., a 5 by 5 filter, then the first two rows (i.e., rows j0 and j1) would be mirrored about horizontal boundary 206 and the first two columns (i.e., columns i0 and i1) would be mirrored about vertical boundary 209.
In filtering image data, line buffers are typically used to store image data. Generally, the number of lines (or rows) in the line buffers is equal to the number of rows in the filter used. Thus, for example, if the filter is one such as filter 210 shown in FIG. 2, then three-lines (or three-rows) of line buffers would be used to store image data to be filtered. Each line (or row) of the line buffers would store one row of image data. For example, when filtering pixels in row j0 of image data 205, the first, second, and third lines of the line buffers would be storing data from rows j0, j0, and j1, respectively. When filtering pixels in row j1 of image data 210, the first, second, and third lines of the line buffers would be storing data from rows j0, j1, and j2, respectively. Further, when filtering pixels in row j2 of image data 210, the first, second, and third lines of the line buffers would be storing data from rows j1, j2, and j3, respectively. One way to efficiently manage data in the line buffers as the filtering transitions from row j1 to row j2 is to move data in each line of the line buffers up by one row and to fill the last line with data from a new row, i.e., row j3. This is relatively simple for the row j1 to row j2 transition. However, it can be more complicated for some row transitions where the filter covers mirrored rows above or below horizontal boundaries of the image data, particularly mirrored rows below the lower horizontal boundary, e.g., lower horizontal boundary 208 in FIG. 2.
Thus, there is a need for efficiently managing image data in line buffers, particularly when filtering pixels that involves use of mirrored image data.